﻿using AutoMapper;
using mozhi.smarterp.Business.Products;
using mozhi.smarterp.Business.Purchases;
using mozhi.smarterp.Business.Purchases.Order;
using mozhi.smarterp.Business.Purchases.ProductPrices;
using mozhi.smarterp.Business.Purchases.Receipt;
using mozhi.smarterp.Business.Purchases.Requisition;
using mozhi.smarterp.Business.Sales;
using mozhi.smarterp.Business.Sales.ProductPrice;

namespace mozhi.smarterp.Business;

public class BusinessApplicationAutoMapperProfile : Profile
{
    public BusinessApplicationAutoMapperProfile()
    {
        /* You can configure your AutoMapper mapping configuration here.
         * Alternatively, you can split your mapping configurations
         * into multiple profile classes for a better organization. */

        CreateMap<ProductPurchaseSetting, ProductPurchaseSettingDto>()
            .ForMember(dest=>dest.ProductCode , opts=>opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.PurchaseUnitName, opts => opts.Ignore())
            .ForMember(dest => dest.DefaultPurchaserName, opts => opts.Ignore())
            .ForMember(dest => dest.DefaultSupplierName, opts => opts.Ignore());

        CreateMap<ProductInventorySetting, ProductInventorySettingDto>()
            .ForMember(dest => dest.ProductCode, opts => opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.DefaultWarehouseName, opts => opts.Ignore())
            .ForMember(dest => dest.DefaultLocationName, opts => opts.Ignore());

        CreateMap<PurchaseRequisition, PurchaseRequisitionDto>()
             .ForMember(dest => dest.ApplicantName, opts => opts.Ignore())
             .ForMember(dest => dest.DepartmentName, opts => opts.Ignore())
             .ForMember(dest => dest.CurrencyName, opts => opts.Ignore());

        CreateMap<PurchaseRequisitionItem, PurchaseRequisitionItemDto>()
            .ForMember(dest => dest.RequisitionUnitId, opts => opts.MapFrom(src=>src.AuxiliaryUnitId))
            .ForMember(dest => dest.RequisitionQuantity, opts => opts.MapFrom(src => src.AuxiliaryQuantity))
            .ForMember(dest => dest.ProductCode, opts => opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.TaxRateName, opts => opts.Ignore())
            .ForMember(dest => dest.RequisitionUnitName, opts => opts.Ignore())
            .ForMember(dest => dest.BasicUnitName, opts => opts.Ignore())
            .ForMember(dest => dest.SuggestedSupplierName, opts => opts.Ignore());

        CreateMap<PurchaseOrder, PurchaseOrderDto>()
             .ForMember(dest => dest.PurchaserName, opts => opts.Ignore())
             .ForMember(dest => dest.DepartmentName, opts => opts.Ignore())
             .ForMember(dest => dest.CurrencyName, opts => opts.Ignore())
             .ForMember(dest => dest.SupplierName, opts => opts.Ignore());

        CreateMap<PurchaseOrderItem, PurchaseOrderItemDto>()
            .ForMember(dest => dest.PurchaseUnitId, opts => opts.MapFrom(src => src.AuxiliaryUnitId))
            .ForMember(dest => dest.PurchaseQuantity, opts => opts.MapFrom(src => src.AuxiliaryQuantity))
            .ForMember(dest => dest.ProductCode, opts => opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.TaxRateName, opts => opts.Ignore())
            .ForMember(dest => dest.PurchaseUnitName, opts => opts.Ignore())
            .ForMember(dest => dest.BasicUnitName, opts => opts.Ignore());

        CreateMap<PurchaseReceipt, PurchaseReceiptDto>()
            .ForMember(dest => dest.PurchaserName, opts => opts.Ignore())
            .ForMember(dest => dest.DepartmentName, opts => opts.Ignore())
            .ForMember(dest => dest.PurchaseDepartmentName, opts => opts.Ignore())
            .ForMember(dest => dest.CurrencyName, opts => opts.Ignore())
            .ForMember(dest => dest.SupplierName, opts => opts.Ignore());

        CreateMap<PurchaseReceiptItem, PurchaseReceiptItemDto>()
            .ForMember(dest => dest.PurchaseUnitId, opts => opts.MapFrom(src => src.AuxiliaryUnitId))
            .ForMember(dest => dest.PurchaseQuantity, opts => opts.MapFrom(src => src.AuxiliaryQuantity))
            .ForMember(dest => dest.ProductCode, opts => opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.TaxRateName, opts => opts.Ignore())
            .ForMember(dest => dest.PurchaseUnitName, opts => opts.Ignore())
            .ForMember(dest => dest.WarehouseName, opts => opts.Ignore())
            .ForMember(dest => dest.LocationName, opts => opts.Ignore())
            .ForMember(dest => dest.ReceiptQuantity, opts => opts.Ignore())
            .ForMember(dest => dest.BasicUnitName, opts => opts.Ignore());

        CreateMap<PurchaseOrderAdvancePaymentItem, PurchaseOrderAdvancePaymentItemDto>()
             .ForMember(dest => dest.AdvancePaymentNumber, opts => opts.Ignore())
             .ForMember(dest => dest.PaymentAmountFr, opts => opts.Ignore());

        CreateMap<SaleProductPrice, SaleProductPriceDto>()
            .ForMember(dest => dest.CustomerCode, opts => opts.Ignore())
            .ForMember(dest => dest.CusomterName, opts => opts.Ignore())
            .ForMember(dest => dest.CurrencyName, opts => opts.Ignore());

        CreateMap<SaleProductPriceItem, SaleProductPriceItemDto>()
            .ForMember(dest => dest.ProductCode, opts => opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.TaxRateName, opts => opts.Ignore())
            .ForMember(dest => dest.BasicUnitName, opts => opts.Ignore());

        CreateMap<PurchaseProductPrice, PurchaseProductPriceDto>()
           .ForMember(dest => dest.SupplierName, opts => opts.Ignore())
           .ForMember(dest => dest.CurrencyName, opts => opts.Ignore());

        CreateMap<PurchaseProductPriceItem, PurchaseProductPriceItemDto>()
            .ForMember(dest => dest.ProductCode, opts => opts.Ignore())
            .ForMember(dest => dest.ProductName, opts => opts.Ignore())
            .ForMember(dest => dest.ProductModel, opts => opts.Ignore())
            .ForMember(dest => dest.TaxRateName, opts => opts.Ignore())
            .ForMember(dest => dest.BasicUnitName, opts => opts.Ignore());
    }
}
